﻿@using ES.Models
@{var sales = (IList<Sale>)ViewBag.Sales;
  var basketProducts = (IList<Product>)ViewBag.BasketProducts;
}
@if (sales.Count != 0)
{
    <h3 style="height: 20px; border-bottom: 1px solid #f3f3f3;">
        Satın Aldıklarım</h3>
    <table class="sale-productList">
        <th>
            Satış No
        </th>
        <th>
            Ürün Başlığı
        </th>
        <th>
            Fiyatı
        </th>
        <th>
            Satış durumu
        </th>
        <th>
            Son İşlem Tarihi
        </th>
        <th>
            Teslimat Adresi
        </th>
        <th>
            Fatura Adresi
        </th>
        @foreach (var item in sales)
        {
            <tr>
                <td>@item.Id
                </td>
                <td>
                    @item.Product.Title
                </td>
                <td>
                    @(((item.Product.Price * item.Product.Kdv) / 100) + item.Product.Price)
                    TL
                </td>
                <td>
                    @{
            if (item.SaleState == (short)SaleState.PendingCheck)
            {<abbr>Onay Bekliyor</abbr>}
            else if ((item.SaleState == (short)SaleState.PendingDelivery))
            {<abbr>Kargoda Bekliyor</abbr> }
            else if ((item.SaleState == (short)SaleState.Complated))
            {<abbr>Satış Tamamlandı</abbr> }
            else if ((item.SaleState == (short)SaleState.Cancel))
            {<abbr>Satış İptal Edildi.</abbr> }
            else if ((item.SaleState == (short)SaleState.Checked))
            {<abbr>Onaylandı.Kargoya yollanacak</abbr> }
            else if ((item.SaleState == (short)SaleState.ComplateDelivery))
            {<abbr>Ulaştırıldı</abbr> }
                    }
                </td>
                <td>
                    @(item.LastUpdateDate ?? item.RecordDate)
                </td>
                <td>@item.DeliveryAdress
                </td>
                <td>
                    @item.BillAdress
                </td>
            </tr>
            
        }
    </table>
}
@if (basketProducts.Count != 0)
{
    <h3 style="height: 20px; border-bottom: 1px solid #f3f3f3;">
        Sepetim</h3>
    <div class="tab-content" style="display: block; float: left;">
        <div class="items" style="width: 750px !important;">
            <div class="cl">
                &nbsp;</div>
            <ul>
                @foreach (var item in basketProducts)
                {
                    <li>
                        @{Html.RenderPartial("SimpleProduct", item);}
                        <a class="removebasketBtn" href="@Url.Action("RemoveBasket", "My", new { id = item.Id })">
                            Sepetten Çıkar</a> <a class="saleBtn" href="@Url.Action("Sale", "Product", new { id = item.Id })">
                                Satın Al </a></li>
                }
            </ul>
            <div class="cl">
                &nbsp;</div>
        </div>
    </div>
}